﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using log4net;
using System.Reflection;

namespace AnyOffice.general.vehicle
{
    public partial class show_detail : ModulePage
    {

        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

      
        protected void Page_Load(object sender, EventArgs e)
        {
            int vehicleId = (Request.QueryString["vehicle_id"] != null) ? int.Parse(Request.QueryString["vehicle_id"]) : 0;
            DataTable table = new VehicleDao().SelectByVehicleId(base.Conn, vehicleId);
            if (table.Rows.Count == 0)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowMessage("无车辆信息");
            }
            else
            {
                this.litNumber.Text = (table.Rows[0]["Number"] != DBNull.Value) ? table.Rows[0]["Number"].ToString() : "";
                if (table.Rows[0]["Photo"] != DBNull.Value)
                {
                    this.litPhoto.Text = "<a href=\"photo.aspx?vehicle_id=" + vehicleId.ToString() + "\" target=\"_blank\" title=\"点击查看放大图片\"><img src=\"photo.aspx?vehicle_id=" + vehicleId.ToString() + "\" width=\"150\" height=\"140\" border=\"0\"></a>";
                }
                this.litModel.Text = (table.Rows[0]["Model"] != DBNull.Value) ? table.Rows[0]["Model"].ToString() : "";
                this.litType.Text = (table.Rows[0]["Type"] != DBNull.Value) ? table.Rows[0]["Type"].ToString() : "";
                this.litDriver.Text = (table.Rows[0]["Driver"] != DBNull.Value) ? table.Rows[0]["Driver"].ToString() : "";
                this.litStatus.Text = (table.Rows[0]["Status"] != DBNull.Value) ? table.Rows[0]["Status"].ToString() : "";
                if (table.Rows[0]["OrderNums"] != DBNull.Value)
                {
                    string str = string.Empty;
                    if (Convert.ToInt32(table.Rows[0]["OrderNums"].ToString()) == 0)
                    {
                        str = "无预定信息";
                    }
                    else
                    {
                        str = "<a href=\"#\" onclick=\"window.open('order_detail.aspx?vehicle_id=" + table.Rows[0]["VehicleId"].ToString() + "','order_detail','height=400,width=700,status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,left=250,top=170,resizable=yes');\" title=\"点击查看详情\">共" + table.Rows[0]["OrderNums"].ToString() + "条预定信息</a>";
                    }
                    this.litOrderInfo.Text = str;
                }
            }
        } 

    }
}
